home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / ntsetact / frmprop.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-03-01  |  14.6 KB  |  419 lines

  1. VERSION 5.00
  2. Begin VB.Form FrmProperty 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Service property"
  5.    ClientHeight    =   6540
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   7350
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   6540
  13.    ScaleWidth      =   7350
  14.    ShowInTaskbar   =   0   'False
  15.    StartUpPosition =   1  'CenterOwner
  16.    Begin VB.CommandButton btnChange 
  17.       Caption         =   "Change"
  18.       Height          =   375
  19.       Left            =   6000
  20.       TabIndex        =   36
  21.       Top             =   6060
  22.       Width           =   1275
  23.    End
  24.    Begin VB.CommandButton btnCancel 
  25.       Caption         =   "Cancel"
  26.       Height          =   375
  27.       Left            =   4620
  28.       TabIndex        =   35
  29.       Top             =   6060
  30.       Width           =   1275
  31.    End
  32.    Begin VB.Frame Frame3 
  33.       Caption         =   "Service type"
  34.       Height          =   855
  35.       Left            =   60
  36.       TabIndex        =   27
  37.       Top             =   5040
  38.       Width           =   7215
  39.       Begin VB.CheckBox cbxRecognizer 
  40.          Caption         =   "Recognizer driver"
  41.          Height          =   195
  42.          Left            =   5460
  43.          TabIndex        =   34
  44.          Top             =   240
  45.          Width           =   1695
  46.       End
  47.       Begin VB.CheckBox cbxInteractive 
  48.          Caption         =   "Interactive process"
  49.          Height          =   195
  50.          Left            =   3960
  51.          TabIndex        =   33
  52.          Top             =   540
  53.          Width           =   1695
  54.       End
  55.       Begin VB.CheckBox cbxAdapter 
  56.          Caption         =   "Adapter"
  57.          Height          =   195
  58.          Left            =   3960
  59.          TabIndex        =   32
  60.          Top             =   240
  61.          Width           =   1695
  62.       End
  63.       Begin VB.CheckBox cbxWin32Shared 
  64.          Caption         =   "win32 shared process"
  65.          Height          =   195
  66.          Left            =   1980
  67.          TabIndex        =   31
  68.          Top             =   540
  69.          Width           =   1935
  70.       End
  71.       Begin VB.CheckBox cbxFileDriver 
  72.          Caption         =   "File system driver"
  73.          Height          =   195
  74.          Left            =   1980
  75.          TabIndex        =   30
  76.          Top             =   240
  77.          Width           =   1695
  78.       End
  79.       Begin VB.CheckBox cbxWin32Own 
  80.          Caption         =   "Win32 own process"
  81.          Height          =   195
  82.          Left            =   120
  83.          TabIndex        =   29
  84.          Top             =   540
  85.          Width           =   1755
  86.       End
  87.       Begin VB.CheckBox cbxKernelDriver 
  88.          Caption         =   "Kernel driver"
  89.          Height          =   195
  90.          Left            =   120
  91.          TabIndex        =   28
  92.          Top             =   240
  93.          Width           =   1455
  94.       End
  95.    End
  96.    Begin VB.Frame Frame2 
  97.       Caption         =   "Error control"
  98.       Height          =   675
  99.       Left            =   60
  100.       TabIndex        =   22
  101.       Top             =   4320
  102.       Width           =   7215
  103.       Begin VB.OptionButton rbnIgnore 
  104.          Caption         =   "Ignore"
  105.          Height          =   195
  106.          Left            =   180
  107.          TabIndex        =   26
  108.          Top             =   300
  109.          Width           =   1155
  110.       End
  111.       Begin VB.OptionButton rbnNormal 
  112.          Caption         =   "Normal"
  113.          Height          =   195
  114.          Left            =   1380
  115.          TabIndex        =   25
  116.          Top             =   300
  117.          Width           =   1155
  118.       End
  119.       Begin VB.OptionButton rbnSevere 
  120.          Caption         =   "Severe"
  121.          Height          =   195
  122.          Left            =   2940
  123.          TabIndex        =   24
  124.          Top             =   300
  125.          Width           =   1155
  126.       End
  127.       Begin VB.OptionButton rbnCritical 
  128.          Caption         =   "Critical"
  129.          Height          =   195
  130.          Left            =   4440
  131.          TabIndex        =   23
  132.          Top             =   300
  133.          Width           =   1155
  134.       End
  135.    End
  136.    Begin VB.Frame Frame1 
  137.       Caption         =   "Startup"
  138.       Height          =   675
  139.       Left            =   60
  140.       TabIndex        =   16
  141.       Top             =   3600
  142.       Width           =   7215
  143.       Begin VB.OptionButton rbnDisabled 
  144.          Caption         =   "Disabled"
  145.          Height          =   195
  146.          Left            =   5820
  147.          TabIndex        =   21
  148.          Top             =   300
  149.          Width           =   1155
  150.       End
  151.       Begin VB.OptionButton rbnManual 
  152.          Caption         =   "Manual"
  153.          Height          =   195
  154.          Left            =   4440
  155.          TabIndex        =   20
  156.          Top             =   300
  157.          Width           =   1155
  158.       End
  159.       Begin VB.OptionButton rbnAutomatic 
  160.          Caption         =   "Automatic"
  161.          Height          =   195
  162.          Left            =   2940
  163.          TabIndex        =   19
  164.          Top             =   300
  165.          Width           =   1155
  166.       End
  167.       Begin VB.OptionButton rbnSystemStart 
  168.          Caption         =   "SystemStart"
  169.          Height          =   195
  170.          Left            =   1380
  171.          TabIndex        =   18
  172.          Top             =   300
  173.          Width           =   1155
  174.       End
  175.       Begin VB.OptionButton rbnBoot 
  176.          Caption         =   "Boot"
  177.          Height          =   195
  178.          Left            =   180
  179.          TabIndex        =   17
  180.          Top             =   300
  181.          Width           =   1155
  182.       End
  183.    End
  184.    Begin VB.TextBox edtPassword 
  185.       Height          =   345
  186.       Left            =   1800
  187.       TabIndex        =   14
  188.       Top             =   3120
  189.       Width           =   2175
  190.    End
  191.    Begin VB.TextBox edtAccount 
  192.       Height          =   345
  193.       Left            =   1800
  194.       TabIndex        =   12
  195.       Top             =   2700
  196.       Width           =   2175
  197.    End
  198.    Begin VB.TextBox edtOrderWithinGroup 
  199.       BackColor       =   &H8000000F&
  200.       Enabled         =   0   'False
  201.       Height          =   345
  202.       Left            =   1800
  203.       TabIndex        =   10
  204.       Top             =   2160
  205.       Width           =   2175
  206.    End
  207.    Begin VB.ComboBox cmbLoadOrder 
  208.       Height          =   315
  209.       Left            =   1800
  210.       TabIndex        =   9
  211.       Top             =   1740
  212.       Width           =   2175
  213.    End
  214.    Begin VB.TextBox memDependencies 
  215.       Height          =   1755
  216.       Left            =   4200
  217.       MultiLine       =   -1  'True
  218.       ScrollBars      =   2  'Vertical
  219.       TabIndex        =   7
  220.       Top             =   1740
  221.       Width           =   3075
  222.    End
  223.    Begin VB.TextBox EdtBinaryFile 
  224.       Height          =   345
  225.       Left            =   1800
  226.       TabIndex        =   5
  227.       Top             =   960
  228.       Width           =   5475
  229.    End
  230.    Begin VB.TextBox EdtDisplayName 
  231.       Height          =   345
  232.       Left            =   1800
  233.       TabIndex        =   3
  234.       Top             =   540
  235.       Width           =   5475
  236.    End
  237.    Begin VB.TextBox edtServiceName 
  238.       BackColor       =   &H8000000F&
  239.       Enabled         =   0   'False
  240.       Height          =   345
  241.       Left            =   1800
  242.       TabIndex        =   1
  243.       Top             =   120
  244.       Width           =   5475
  245.    End
  246.    Begin VB.Label Label8 
  247.       Caption         =   "Password"
  248.       Height          =   255
  249.       Left            =   120
  250.       TabIndex        =   15
  251.       Top             =   3180
  252.       Width           =   1395
  253.    End
  254.    Begin VB.Label Label7 
  255.       Caption         =   "Account to start under"
  256.       Height          =   255
  257.       Left            =   120
  258.       TabIndex        =   13
  259.       Top             =   2760
  260.       Width           =   1635
  261.    End
  262.    Begin VB.Label Label6 
  263.       Caption         =   "Order within group"
  264.       Height          =   255
  265.       Left            =   120
  266.       TabIndex        =   11
  267.       Top             =   2220
  268.       Width           =   1455
  269.    End
  270.    Begin VB.Label Label5 
  271.       Caption         =   "Load order group"
  272.       Height          =   255
  273.       Left            =   120
  274.       TabIndex        =   8
  275.       Top             =   1800
  276.       Width           =   1455
  277.    End
  278.    Begin VB.Label Label4 
  279.       Caption         =   "Dependencies"
  280.       Height          =   255
  281.       Left            =   4200
  282.       TabIndex        =   6
  283.       Top             =   1440
  284.       Width           =   1695
  285.    End
  286.    Begin VB.Label Label3 
  287.       Caption         =   "Binary file name"
  288.       Height          =   255
  289.       Left            =   120
  290.       TabIndex        =   4
  291.       Top             =   1020
  292.       Width           =   1155
  293.    End
  294.    Begin VB.Label Label2 
  295.       Caption         =   "Displayed name"
  296.       Height          =   255
  297.       Left            =   120
  298.       TabIndex        =   2
  299.       Top             =   600
  300.       Width           =   1155
  301.    End
  302.    Begin VB.Label Label1 
  303.       Caption         =   "Sevice name"
  304.       Height          =   255
  305.       Left            =   120
  306.       TabIndex        =   0
  307.       Top             =   180
  308.       Width           =   1155
  309.    End
  310. Attribute VB_Name = "FrmProperty"
  311. Attribute VB_GlobalNameSpace = False
  312. Attribute VB_Creatable = False
  313. Attribute VB_PredeclaredId = True
  314. Attribute VB_Exposed = False
  315. Private Sub btnCancel_Click()
  316.   Unload FrmProperty
  317. End Sub
  318. Private Sub btnChange_Click()
  319.   On Error GoTo ErrorHandler
  320.   If MsgBox("Are you sure to change service properties?. It may cause system damage !", vbExclamation + vbOKCancel) = vbOK Then
  321.     Set NTServiceX = FrmServiceManager.NTServiceX
  322.     NTServiceX.ManagerAccess = M_CONNECT + M_MODIFY_BOOT_CONFIG
  323.     NTServiceX.ServiceAccess = S_ALL_ACCESS
  324.     NTServiceX.ActiveManager = True
  325.     NTServiceX.ActiveService = True
  326.     AServiceType = 0
  327.     If cbxKernelDriver.Value = Checked Then AServiceType = AServiceType + KERNEL_DRIVER
  328.     If cbxFileDriver.Value = Checked Then AServiceType = AServiceType + FILE_SYSTEM_DRIVER
  329.     If cbxAdapter.Value = Checked Then AServiceType = AServiceType + ADAPTER
  330.     If cbxRecognizer.Value = Checked Then AServiceType = AServiceType + RECOGNIZER_DRIVER
  331.     If cbxWin32Own.Value = Checked Then AServiceType = AServiceType + WIN32_OWN_PROCESS
  332.     If cbxWin32Shared.Value = Checked Then AServiceType = AServiceType + WIN32_SHARE_PROCESS
  333.     If cbxInteractive.Value = Checked Then AServiceType = AServiceType + INTERACTIVE_PROCESS
  334.     NTServiceX.ServiceType = AServiceType
  335.     If rbnBoot.Value Then NTServiceX.StartType = BOOT_START Else
  336.     If rbnSystemStart.Value Then NTServiceX.StartType = SYSTEM_START Else
  337.     If rbnAutomatic.Value Then NTServiceX.StartType = AUTO_START Else
  338.     If rbnManual.Value Then NTServiceX.StartType = DEMAND_START Else
  339.     If rbnDisabled.Value Then NTServiceX.StartType = DISABLED
  340.         
  341.     If rbnIgnore.Value Then NTServiceX.ErrorControl = ERROR_IGNORE Else
  342.     If rbnNormal.Value Then NTServiceX.ErrorControl = ERROR_NORMAL Else
  343.     If rbnSevere.Value Then NTServiceX.ErrorControl = ERROR_SEVERE Else
  344.     If rbnCritical.Value Then NTServiceX.ErrorControl = ERROR_CRITICAL
  345.     NTServiceX.BinaryPathName = EdtBinaryFile.Text
  346.     NTServiceX.DisplayName = EdtDisplayName.Text
  347.     NTServiceX.LoadOrder = cmbLoadOrder.Text
  348.     NTServiceX.Dependencies.Text = memDependencies.Text
  349.     If (edtAccount.Tag > 0) Or (edtPassword.Tag > 0) Then
  350.       NTServiceX.Password = edtPassword.Text
  351.       NTServiceX.ServiceStartName = edtAccount.Text
  352.     End If
  353.         
  354. ExitProc:
  355.     NTServiceX.ActiveService = False
  356.     NTServiceX.ActiveManager = False
  357.     FrmServiceManager.Sleep (2)
  358.     End If
  359.   Unload FrmProperty
  360. Exit Sub
  361. ErrorHandler:
  362.   MsgBox (Err.Description)
  363.   Resume ExitProc
  364. End Sub
  365. Private Sub edtAccount_Change()
  366.   edtAccount.Tag = 1
  367. End Sub
  368. Private Sub edtPassword_Change()
  369.   edtPassword.Tag = 1
  370. End Sub
  371. Private Sub Form_Load()
  372.   On Error GoTo ErrorHandler
  373.   btnChange.Enabled = Not (FrmServiceManager.cbxReadOnly.Value = 1)
  374.   Set Item = FrmServiceManager.List.Items(FrmServiceManager.lbxServices.ListIndex)
  375.   Set NTServiceX = FrmServiceManager.NTServiceX
  376.   edtServiceName.Text = Item.ServiceName
  377.   NTServiceX.ServiceName = edtServiceName.Text
  378.   NTServiceX.ManagerAccess = M_CONNECT
  379.   NTServiceX.ServiceAccess = S_QUERY_CONFIG
  380.   NTServiceX.ActiveManager = True
  381.   NTServiceX.ActiveService = True
  382.   EdtDisplayName.Text = NTServiceX.DisplayName
  383.   EdtBinaryFile.Text = NTServiceX.BinaryPathName
  384.   cmbLoadOrder.Text = NTServiceX.LoadOrder
  385.   edtOrderWithinGroup.Text = Format(NTServiceX.TagId, "0")
  386.   memDependencies.Text = NTServiceX.Dependencies.Text
  387.   edtAccount.Text = NTServiceX.ServiceStartName
  388.   edtPassword.Text = "****************"
  389.   edtAccount.Tag = 0
  390.   edtPassword.Tag = 0
  391.   If NTServiceX.StartType = BOOT_START Then rbnBoot.Value = True Else
  392.   If NTServiceX.StartType = SYSTEM_START Then rbnSystemStart.Value = True Else
  393.   If NTServiceX.StartType = AUTO_START Then rbnAutomatic.Value = True Else
  394.   If NTServiceX.StartType = DEMAND_START Then rbnManual.Value = True Else
  395.   If NTServiceX.StartType = DISABLED Then rbnDisabled.Value = True
  396.   If NTServiceX.ErrorControl = ERROR_IGNORE Then rbnIgnore.Value = True Else
  397.   If NTServiceX.ErrorControl = ERROR_NORMAL Then rbnNormal.Value = True Else
  398.   If NTServiceX.ErrorControl = ERROR_SEVERE Then rbnSevere.Value = True Else
  399.   If NTServiceX.ErrorControl = ERROR_CRITICAL Then rbnCritical.Value = True
  400.   If (KERNEL_DRIVER And NTServiceX.ServiceType) > 0 Then cbxKernelDriver.Value = Checked
  401.   If (FILE_SYSTEM_DRIVER And NTServiceX.ServiceType) > 0 Then cbxFileDriver.Value = Checked
  402.   If (ADAPTER And NTServiceX.ServiceType) > 0 Then cbxAdapter.Value = Checked
  403.   If (RECOGNIZER_DRIVER And NTServiceX.ServiceType) > 0 Then cbxRecognizer.Value = Checked
  404.   If (WIN32_OWN_PROCESS And NTServiceX.ServiceType) > 0 Then cbxWin32Own.Value = Checked
  405.   If (WIN32_SHARE_PROCESS And NTServiceX.ServiceType) > 0 Then cbxWin32Shared.Value = Checked
  406.   If (INTERACTIVE_PROCESS And NTServiceX.ServiceType) > 0 Then cbxInteractive.Value = Checked
  407.   Set AList = NTServiceX.GetOrderGroupList
  408.   For i = 0 To AList.Count - 1
  409.     cmbLoadOrder.AddItem (AList.Item(i))
  410.   Next i
  411. ExitProc:
  412.   NTServiceX.ActiveService = False
  413.   NTServiceX.ActiveManager = False
  414.   Exit Sub
  415. ErrorHandler:
  416.   MsgBox (Err.Description)
  417.   Resume ExitProc
  418. End Sub
  419.